<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #myCanvas{
            border: 1px solid red;
        }
    </style>
</head>
<body>
    <center>
        <canvas id="myCanvas" width="400" height="400">

        </canvas>
    </center>
    
</body>
<script>
    /** @type {HTMLCanvasElement} */
    let myCanvas=document.querySelector("#myCanvas");
    let ctx=myCanvas.getContext("2d");
    
    ctx.rect(50,20,200,120);    
    ctx.stroke();
    ctx.fillStyle="green";
    ctx.clip();//准备剪切
    ctx.arc(200,100,70,0,2*Math.PI,true);//剪切掉一个圆
    ctx.fill();
</script>
</html>